package com.qingxin.sys.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;

/**
 * 权限表
 * @author Administrator
 *
 */
@Entity
@Table(name = "sys_permission")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class SysPermission extends BaseEntity implements java.io.Serializable {
	private static final long serialVersionUID = -1045298786332993688L;

	private String perid;
	private String pid;
	private String per_code;
	private String per_name;
	private String remark;
	private String url;
	private String icon;
	private String type;
	private Integer per_index;
	private Set<SysRoleRights> sysRoleRights = new HashSet<>(0);
	
	private boolean hasRights;
	
	public SysPermission() {
	}
	
	
	public SysPermission(String perid) {
		this.perid = perid;
	}

	
	public SysPermission(String per_code, String url) {
		this.per_code = per_code;
		this.url = url;
	}


	public SysPermission(String perid, String pid, String per_name) {
		this.perid = perid;
		this.pid = pid;
		this.per_name = per_name;
	}


	@Id
	@Column(name = "perid", unique = true, nullable = false, length = 32)
	public String getPerid() {
		return perid;
	}
	public void setPerid(String perid) {
		this.perid = perid;
	}

	@Column(name = "pid", length = 32)
	public String getPid() {
		return pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}

	@Column(name = "per_code", length = 50)
	public String getPer_code() {
		return per_code;
	}
	public void setPer_code(String per_code) {
		this.per_code = per_code;
	}

	@Column(name = "per_name", length = 50)
	public String getPer_name() {
		return per_name;
	}
	public void setPer_name(String per_name) {
		this.per_name = per_name;
	}

	@Column(name = "remark", length = 200)
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "url", length = 100)
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "icon", length = 100)
	public String getIcon() {
		return icon;
	}
	public void setIcon(String icon) {
		this.icon = icon;
	}
	
	@Column(name = "type", length = 20)
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	@Column(name = "per_index")
	public Integer getPer_index() {
		return per_index;
	}
	public void setPer_index(Integer per_index) {
		this.per_index = per_index;
	}

	
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sysPermission")
	@JsonIgnore
	public Set<SysRoleRights> getSysRoleRights() {
		return sysRoleRights;
	}
	public void setSysRoleRights(Set<SysRoleRights> sysRoleRights) {
		this.sysRoleRights = sysRoleRights;
	}


	@Transient
	public boolean isHasRights() {
		return hasRights;
	}
	public void setHasRights(boolean hasRights) {
		this.hasRights = hasRights;
	}
	
}
